package com.guigu.controller;

import com.guigu.utils.SMSUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 短信 前端控制器
 * </p>
 *
 * @author Mr.Zhang
 * @since 2025-03-12
 */
@CrossOrigin
@Controller
@RequestMapping("/sms")
public class SMSController {

    /**
     * 发送短信验证码接口
     * @return 发送结果
     *
     */
    @PostMapping("/sendValidateCode")
    @ResponseBody
    public Boolean sendValidateCode(@RequestBody Map<String,Object> map) {
        try {
            String phoneNumber = (String) map.get("phoneNumber");
            String code = (String) map.get("code");
            Boolean b = SMSUtils.sendShortMessage(SMSUtils.ORDER_NOTICE, phoneNumber, code);
            return b;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}
